﻿using System;
using System.Net;

namespace ProxyFinder.Strategies {
    public class BaseCredentialStrategy: IProxyFinderStrategy {

        public virtual IWebProxy GetProxy(Uri uri) {
            return null;
        }

        /// <summary>
        /// Returns the system proxy to be used to create a request for the given Uri.
        /// </summary>
        /// <param name="uri">The Uri object that the proxy is to be used for.</param>
        /// <returns></returns>
        protected static WebProxy GetSystemProxy(Uri uri) {
            // WebRequest.DefaultWebProxy seems to be more capable in terms of getting the default
            // proxy settings instead of the WebRequest.GetSystemProxy()
            IWebProxy proxy = WebRequest.DefaultWebProxy;
            string proxyUrl = proxy.GetProxy(uri).AbsoluteUri;
            return new WebProxy(proxyUrl);
        }
    }
}
